Constructs a model_spec object representing the right-hand side of a
regression formula as a set of terms. Accepts unquoted variable names,
string literals, or R expressions (e.g. I(x^2)).
Usage
model_spec(..., intercept = TRUE)
# S3 method for class 'model_spec'
print(x, ...)
# S3 method for class 'model_spec'
as.character(x, ...)Arguments
- ...
Terms to include. May be unquoted names (
cyl), string literals ("cyl"), or R expressions (I(x^2)). To inject a variable whose value is the term name, use!!(bang-bang):model_spec(x1, !!my_var).- intercept
Logical. When
FALSEthe formula produced byto_formula(and the formula sent to the regression function insidefit_models) will suppress the intercept (equivalent to adding- 1or0 +to the formula). DefaultTRUE.- x
A
model_specobject.
Examples
model_spec(cyl, disp, hp)
#> model_spec: ~ cyl + disp + hp
model_spec("cyl", "disp")
#> model_spec: ~ cyl + disp
model_spec(cyl, I(disp^2))
#> model_spec: ~ cyl + I(disp^2)
model_spec(cyl, intercept = FALSE)
#> model_spec: ~ 0 + cyl
# Programmatic use: inject a variable's value with !!
tmp <- "hp"
model_spec(cyl, disp, !!tmp)
#> model_spec: ~ cyl + disp + hp